<%@page contentType="text/html;charset=UTF-8" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<%@page import="be.destin.skos.core.SkosManager" %>
<%@page import="be.destin.skos.html.SkosHtmlManager" %>
<%@page import="be.destin.skos.html.SkosHtmlTable" %>
<%@page import="be.destin.skos.core.SchemeInterface" %>
<%@page import="be.destin.skos.core.SchemeUsage" %>
<%@page import="be.destin.skos.core.ConceptScheme" %>
<%@page import="be.destin.skos.core.Concept" %>
<%@page import="be.destin.skos.core.Term" %>
<%@page import="be.destin.skos.search.SkosSearch" %>
<%@page import="be.destin.skos.search.LabelMatchType" %>
<%@page import="be.destin.skos.view.SkosView" %>
<%@page import="be.destin.skos.view.SkosViewType" %>
<%@page import="be.destin.skos.view.SkosViewManager" %>
<%@page import="be.destin.util.Util" %>
<%@page import="java.util.Map" %>
<%@page import="java.util.HashSet" %>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.TreeMap" %>
<%@page import="java.util.StringTokenizer" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%	 
   SkosHtmlManager skosHtmlManager = SkosHtmlManager.getAskosiSessionInstance(request);
   SkosManager skosManager = skosHtmlManager.getSkosManager();
   String language = skosHtmlManager.getLanguage();
   String schemeList = request.getParameter("schemeList");
   String queryList = request.getParameter("queryList");
   int minHit = 0;
   String sMinHit = request.getParameter("minHit");
   if (sMinHit != null && !sMinHit.isEmpty()) minHit = Integer.valueOf(sMinHit);
   int maxHit = 999999999;
   String sMaxHit = request.getParameter("maxHit");
   if (sMaxHit != null && !sMaxHit.isEmpty()) maxHit = Integer.valueOf(sMaxHit);
   if (queryList == null) queryList = "";
   if (schemeList==null) schemeList ="";
   LabelMatchType matchType = LabelMatchType.EXACT;
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/askosi.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/ajaxtags.css" />
<title>Search a whole list</title>
</head>
<body>
<h4><a href="index.jsp" title="All Concept Schemes"><img align="left" src="img/lego3.gif" border="0"/></a></h4>
<form method="post" action="map.jsp">
Schemes:<textarea name="schemeList" rows="10" cols="40"><%=schemeList%></textarea><br/>
Labels:<textarea name="queryList" rows="50" cols="80"><%=queryList%></textarea><br/>
Min: <input name="minHit" value="<%=minHit%>"/>, Max: <input name="maxHit" value="<%=maxHit%>"/>
<input type="submit" name="Map"/>
</form>
<%
if (queryList != null) {
   %><table border="0"><%
  StringTokenizer st = new StringTokenizer(schemeList,"\n; ");
  SchemeInterface[] allSchemes = new SchemeInterface[st.countTokens()];
  int i = 0;
  while (st.hasMoreTokens()) {
	String schemeCode = st.nextToken();
	allSchemes[i] = skosManager.getScheme(schemeCode);
	i++;
  }
  st = new StringTokenizer(queryList,"\n;");
  while (st.hasMoreTokens()) {
	String query = st.nextToken();
	ArrayList<Concept> result = SkosSearch.search(skosHtmlManager,false,allSchemes,query, matchType,null);
    if (result != null && !result.isEmpty() && (result.size()>=minHit) && (result.size()<=maxHit)) {
    %><tr><td><%=query%></td><th><%=result.size()%></th><%
	     for(Concept aConcept: result) {
		    String display = aConcept.toHtmlLabel(skosHtmlManager,true);
			%><td><%=display%></td><%
		 }
	%></tr><%
    }
  }%></table><%
}%>
<%@include file="footer.jnc" %>
